/**
 * 338. 比特位计数
 */
class Solution2 {
    public int[] countBits(int n) {
        int[] ret = new int[n + 1];
        for(int i = 0; i <= n; i++) {
            int tmp = i;
            while(tmp > 0) {
            if((tmp & 1) == 1) ret[i]++;
            tmp = tmp >> 1;
        }
        }
        return ret;
    }
}